package asdf.trial;

import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Queue;

public class PriorityQueueTest
{

    public static void main(String[] args)
    {
        // 自定义比较器
        Comparator<Integer> cmp = new Comparator<Integer>()
        {
            @Override
            public int compare(Integer e1, Integer e2)
            {
                return e1 - e2;
            }
        };
        // 队列
        Queue<Integer> q2 = new PriorityQueue<Integer>(5, cmp);
        q2.add(2);
        q2.add(8);
        q2.add(9);
        q2.add(3);
        for ( int i = 0; i < 4; i++ ) {
            System.out.println(q2.poll());
        }
        //		downQueue(q2);
    }

    private static void downQueue(final Queue<Integer> q2)
    {
        for ( int i = 0; i <= q2.size(); i++ ) {
            new Thread()
            {
                @Override
                public void run()
                {
                    System.out.println("开始下载--" + q2.poll());
                    try {
                        Thread.sleep(1000);
                    } catch ( InterruptedException e ) {
                        e.printStackTrace();
                    }
                }

                ;
            }.start();

        }
    }

}

class testBean
{
    private Integer sort_mark;
    private String  down_url;
    private String  song_name;
    private String  singer_name;
    private String  user;
}